<!--

     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.

-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>package groovy.mock.interceptor</title>
  </head>
  <body>
    <p>The groovy.mock.interceptor is an all-groovy mock testing library.</p>
    <p>Terms:</p>
    <dl>
        <dt>Collaborator</dt>
        <dd>An ordinary Groovy or Java class that's instance or class methods
        are to be called. Calling them can be time-consuming or produce side effects that
        are unwanted when testing (e.g. database operations). </dd>

        <dt>Caller</dt>
        <dd>A Groovy Object that calls methods on the Collaborator, i.e.
        collaborates with it.</dd>

        <dt>Mock</dt>
        <dd>An object that can be used to augment the Collaborator.
        Method calls to the Collaborator will be handled by the Mock, showing a <em>demanded</em>
        <em>behavior</em>. Method calls are <em>expected</em> to occur <em>strictly</em> in the <em>demanded</em>
        sequence with a given <em>range</em> of cardinality. The <em>use</em> of a Mock implicitly
        ends with <em>verifying</em> the <em>expectations</em>.
        </dd>

        <dt>Stub</dt>
        <dd>Much like a Mock but the <em>expectation</em> about sequences of method calls on the Collaborator is
        <em>loose</em>, i.e. calls may occur out of the demanded order as long as the <em>ranges</em>
        of cardinality are met. The <em>use</em> of a Stub does <em>not</em> end with an implicit
        <em>verification</em> since the stubbing effect is typically asserted on the Caller.
        An explicit call to <em>verify</em> can be issued to assert all demanded method call
        have been effected with the specified cardinality.</dd>
    </dl>

    <p>Features:</p>
    <ul>
        <li>typical mock style of <em>failing early</em></li>
        <li>mocks instance and class methods</li>
        <li>mocks final methods and final Collaborators</li>
        <li>mocks Groovy and Java Collaborators (but Caller must be groovy)</li>
        <li>can mock all objects of a given class (or a single Groovy object)</li>
        <li>mocks even if Collaborator cannot be injected into the Caller</li>
        <li>mocks even if Collaborator is not accessible on the Caller (no getter)</li>
        <li>demanded calls specified via recording calls on the Demand object (EasyMock style).</li>
        <li>cardinality specified as Ranges, default is 1..1; 'optional' can be achieved with 0..1</li>
        <li>behavior specified via Closures, allowing static or calculated return values, throwing exceptions,
            asserting argument values, etc. (even tricky sequence constraints
            by sharing state in the testMethod scope between the behavior Closures)</li>
        <li>matching parameter list specified via Closure's parameter list, supporting
            typed or untyped params, default params, and varargs.</li>
        <li>not dependent on any external mock library</li>
    </ul>
   <p>For an extensive list of usages see the unit tests in this package.</p>
  </body>
</html>
